package com.iwhalecloud.bss.kite.cucc.order.accept.process.impl;

import com.iwhalecloud.bss.kite.common.chain.IHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.AcctItemHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.CustomerOrderHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.DataPreparationHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.DataResponseHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.DerivedOrderHandle;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.OrderBeforeSaveHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.OrderCommitHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.OrderConfirmHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.OrderSaveHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.WithdrawOrderCheckHandler;
import com.iwhalecloud.bss.kite.cucc.order.accept.chain.impl.WithdrawOrderHandler;
import com.iwhalecloud.bss.kite.order.client.dto.OrderRequest;
import com.ztesoft.bss.common.util.SpringUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 撤单业务流程处理
 * @author xiao.xuzhang<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2020年2月17日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.order.accept.process.impl <br>
 */
@Component
public class WithdrawOrderProcessor extends AbstractOrderBusinessProcessor {

    @Override
    protected List<IHandler<OrderRequest>> listDefaultHandlers() {
        List<IHandler<OrderRequest>> handlers = new ArrayList<>();

        // 1、数据准备
        handlers.add(SpringUtil.getBean(DataPreparationHandler.class));

        // 2、客户订单处理
        handlers.add(SpringUtil.getBean(CustomerOrderHandler.class));

        // 3、撤单业务校验处理
        handlers.add(SpringUtil.getBean(WithdrawOrderCheckHandler.class));

        // 4、撤单处理
        handlers.add(SpringUtil.getBean(WithdrawOrderHandler.class));

        // 4.1 撤单衍生单处理
        handlers.add(SpringUtil.getBean(DerivedOrderHandle.class));

        // 5、费用处理
        handlers.add(SpringUtil.getBean(AcctItemHandler.class));

        // 6、订单确认处理(订单数据调整或者补充)
        handlers.add(SpringUtil.getBean(OrderConfirmHandler.class));

        // 7.1、订单保存前处理
        handlers.add(SpringUtil.getBean(OrderBeforeSaveHandler.class));

        // 7.2、订单保存处理
        handlers.add(SpringUtil.getBean(OrderSaveHandler.class));

        // 8、订单提交
        handlers.add(SpringUtil.getBean(OrderCommitHandler.class));

        // 9、返回结果处理
        handlers.add(SpringUtil.getBean(DataResponseHandler.class));

        return handlers;
    }
}
